package com.ssm.mapper;

import com.ssm.entity.Book;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface  BookMapper {
    @Select("select * from t_book1")
    List<Book> selectAll();

    @Select("select * from t_book1 where id=#{id}")
    Book selectById(Integer id);

    @Insert("insert into t_book1 values(null,#{bookName},#{author},#{price},#{date},#{publisher},null)")
    void insert(Book book);

    @Update("update t_book1 set book_name=#{bookName},author=#{author},date=#{date},price=#{price},publisher=#{publisher} where id=#{id}")
    void update(Book book);

    @Delete("delete from t_book1 where id = #{id}")
    void deleteById(Integer id);

    @Delete({
            "<script>",
            "DELETE FROM t_book1 WHERE id IN",
            "<foreach item='item' collection='ids' open='(' separator=',' close=')'>",
            "#{item}",
            "</foreach>",
            "</script>"
    })
    void batchDelete(@Param("ids") List<Integer> ids);

}
